package org.jeecgframework.web.controller;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jodd.util.Base64;
import net.sf.json.JSONObject;
import org.apache.commons.httpclient.HttpClient;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.StatusLine;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
import org.jeecgframework.core.common.controller.BaseController;
import org.jeecgframework.core.common.exception.BusinessException;
import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
import org.jeecgframework.core.common.model.json.AjaxJson;
import org.jeecgframework.core.common.model.json.DataGrid;
import org.jeecgframework.core.constant.Globals;
import org.jeecgframework.core.util.*;
import org.jeecgframework.tag.core.easyui.TagUtil;
import org.jeecgframework.web.service.CbsQuickRepairServiceI;
import org.jeecgframework.web.service.CbsServiceServiceI;
import org.jeecgframework.web.service.WxCommonService;
import org.jeecgframework.web.service.ZyCommonService;
import org.jeecgframework.web.service.WxCommonService.ServiceEnum;
import org.jeecgframework.web.system.pojo.base.*;
import org.jeecgframework.web.system.service.SystemService;
import org.jeecgframework.web.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import sun.misc.BASE64Decoder;



/**
 * @Title: Controller
 * @Description: 快速报修
 * @author onlineGenerator
 * @date 2017-04-11 10:41:13
 * @version V1.0   
 *
 */
@Scope("prototype")
@Controller
@RequestMapping("/cbsQuickRepairController")
public class CbsQuickRepairController extends BaseController {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger.getLogger(CbsQuickRepairController.class);

	@Autowired
	private CbsQuickRepairServiceI cbsQuickRepairService;
	@Autowired
	private SystemService systemService;
	@Autowired
	private ZyCommonService zyCommonService;
	@Autowired
	private WxCommonService wxCommonService;
	@Autowired
    private CbsServiceServiceI cbsServiceServiceI;

	private String message;
	
	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}


	/**
	 * 原微信添加快速报修功能
	 * @param ids
	 * @return
	 */
	@RequestMapping(params = "doAdd")
	@ResponseBody
	public AjaxJson doAdd(CbsQuickRepairEntity cbsQuickRepair, HttpServletRequest request,
			@RequestParam(value="faultPic",required=false,defaultValue="")String faultPic) {
		AjaxJson j = new AjaxJson();
		message = "快速报修添加成功";
		try{
			cbsQuickRepairService.saveFaultPics(cbsQuickRepair, faultPic);
			j.setObj(cbsQuickRepair.getOrderNo());
			systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
		}catch(Exception e){
			e.printStackTrace();
			message = "快速报修添加失败";
			throw new BusinessException(e.getMessage());
		}
		j.setMsg(message);
		return j;
	}

	/**
	* 现微信添加快速报修功能
	* 开发人：mhg
	* 时间：2018-04
	* */
	@RequestMapping(params = "doAddNew")
	@ResponseBody
	public AjaxJson doAddNew(HttpServletRequest request,
			@RequestParam(value="faultPic",required=false,defaultValue="")String faultPic) {
		AjaxJson j = new AjaxJson();

        String openId = oConvertUtils.getString(request.getSession().getAttribute("openId"));
        String name = oConvertUtils.getString(request.getSession().getAttribute("name"));
        System.out.println("openId--"+openId);
        TSUser user=systemService.singleResult("from TSUser where openId='"+openId+"'");
        String createBy="";
        String createName="";
        if(user!=null && StringUtil.isNotEmpty(user.getUserName())){
            createBy=user.getUserName();
        }else{
            createBy=openId;
        }
        if(user!=null && StringUtil.isNotEmpty(user.getRealName())){
            createName=user.getRealName();
        }else{
            createName=name;
        }
		message = "快速报修添加成功";
		CbsServiceEntity service=new CbsServiceEntity();
		String sn=request.getParameter("esSn");
		//组装服务单号CR+YYYYMMDD+001(增长)
//		String code ="";
//		Date date = new Date();
//		DateFormat format = new SimpleDateFormat("YYYYMMdd");
//		String time = format.format(date);
//		StringBuffer buffer = new StringBuffer();
//		buffer.append("CR");
//		buffer.append(time);
//		List<Object[]> cbsServiceList = systemService.findListbySql("select * from cbs_service where `code` not LIKE '%-%' AND to_days(create_date) = to_days(now()) ORDER BY create_date desc");
//
//		if (cbsServiceList.size() == 0) {
//			buffer.append("001");
//			code= buffer.toString();
//		} else {
//			String o = (String) cbsServiceList.get(0)[1];
//			String s = o.substring(10, 13);
//			int i = Integer.parseInt(s);
//			i++;
//			if (i <= 9) {
//				buffer.append("00" + i);
//			} else if (i >= 10 && i < 100) {
//				buffer.append("0" + i);
//			} else {
//				buffer.append("" + i);
//			}
//			code = buffer.toString();
//		}

		//新的服务单号
		Map noMap=cbsServiceServiceI.getNo();
		String code=(String) noMap.get("no");

		CbsServiceTypeEntity sType1=systemService.singleResult("from CbsServiceTypeEntity where type=0 and name='故障维修'");
		CbsServiceTypeEntity sType2=systemService.singleResult("from CbsServiceTypeEntity where type=1 and name='普通维修'");
		try{
			service.setCode(code);
			service.setStatus("1");
			service.setServiceType1(sType1);
			service.setServiceType2(sType2);
			service.setSn(request.getParameter("esSn"));
			service.setProductModel(request.getParameter("productModel"));
			service.setZyCinemaName(request.getParameter("cinemaName"));
			service.setDescription(request.getParameter("faultDetail"));
			service.setErrorCode(request.getParameter("faultCode"));
			service.setContactsName(request.getParameter("contactsName"));
			service.setContactsPhone(request.getParameter("contactsPhone"));
			service.setSourceType("2");
			service.setSpeedStatus("0");
			ZyEquipmentSpareEntity zyEquipmentSpare=systemService.singleResult("from ZyEquipmentSpareEntity where sn='"+sn+"'");
			if(zyEquipmentSpare!=null){
				service.setZyEquipmentSpareId(zyEquipmentSpare);
			}
			ZyCinemaEntity cinema=systemService.singleResult("from ZyCinemaEntity where name='"+request.getParameter("cinemaName")+"'");
			if(cinema!=null){
				service.setZyCinemaId(cinema);
				service.setProvince(cinema.getProvince());
				if(cinema.getCity()!=null){
					TSTerritory city=systemService.get(TSTerritory.class,cinema.getCity());
					service.setCity(city);
				}
				service.setAddress(cinema.getAddress());
			}
			String hql="from ZyContactsEntity where cellphone1='"+request.getParameter("contactsPhone")+"' or cellphone2='"+request.getParameter("contactsPhone")+"'";
			List<ZyContactsEntity> zyContactsList=systemService.findHql(hql);
			if(zyContactsList!=null && zyContactsList.size()>0){
				service.setZyContactsId(zyContactsList.get(0));
			}

            service.setCreateBy(createBy);
            service.setCreateName(createName);
            service.setCreateDate(new Date());
			systemService.save(service);
			//添加服务单日志
			wxCommonService.addServiceLog(service.getId());


			if(faultPic!=null && !faultPic.equals("")){
				if(faultPic.contains(",")){
					String[] fileIds=faultPic.split(",");
					for(String id:fileIds){
						ZyFileLogEntity file=systemService.get(ZyFileLogEntity.class,id);
						file.setBusinessKey(service.getId());
						systemService.saveOrUpdate(file);
					}
				}else{
					ZyFileLogEntity file=systemService.get(ZyFileLogEntity.class,faultPic);
					file.setBusinessKey(service.getId());
					systemService.saveOrUpdate(file);
				}

			}


			/*给服务单客户联系人发送微信提醒*/
			//调用微信接口发送
			List<Map<String,String>> list=new ArrayList<>();
			String serviceCode="";
			if(service!=null){
				serviceCode=service.getCode();
			}
			String content="尊敬的客户：您的放映机<"+sn+">的服务申请已提交，服务单号：<"+serviceCode+">。我们会在30分钟内与您联系。【中影巴可客服部】";
			if(StringUtil.isNotEmpty(openId)){
				Map<String,String> map=new HashMap<>();
				map.put("openid",openId);
				map.put("message",content);
				list.add(map);
				wxCommonService.sendMsgForWx(list);
			}


			//发送邮件给HD
			wxCommonService.sendMail(service);


			systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
		}catch(Exception e){
			e.printStackTrace();
			message = "快速报修添加失败";
			throw new BusinessException(e.getMessage());
		}
		j.setMsg(message);
		j.setObj(service);
		return j;
	}

	//当前日期转化为MMdd字符转
	public String getDateStr(Date date) {
		SimpleDateFormat df = new SimpleDateFormat("MMdd");
		String dateStr = df.format(date);
		return dateStr;
	}

	/**
	 * @author xiul
	 * 2017-4-11 下午6:06:42
	 * Description 提交订单成功页面
	 */
	@RequestMapping(params="subQuickRepairSuc")
	public ModelAndView subQuickRepairSuc(HttpServletRequest request){
		request.setAttribute("orderNo", request.getParameter("orderNo"));
		return new ModelAndView("com/wx/repair_query/quick_repair_suc");
	}
	
	/**
	 * @author xiul
	 * 2017-4-11 下午4:45:35
	 * Description 快速报修 提交订单前的 发送验证码
	 */
	@ResponseBody
	@RequestMapping(params="sendVerifyCode")
	public AjaxJson sendVerifyCode(HttpServletRequest request){
		AjaxJson json = new AjaxJson();
		String phoneNo = oConvertUtils.getString(request.getParameter("phoneNumber"));
		String busType = oConvertUtils.getString(request.getParameter("busType"));
		Integer timeOut = StaticValue.SEND_RANDOMCODE_TIMEOUT;

        Map<String, Object> templeteMap = new HashMap<String, Object>();
        templeteMap.put("phoneLastFour", phoneNo.substring(7));
        templeteMap.put("liveTime", timeOut);
		zyCommonService.sendRandomCode(request.getSession().getId(), phoneNo, timeOut, "sms_addQuickRepair.ftl", templeteMap, busType);
		return json;
	}
	
	/**
	 * @author xiul
	 * 2017-4-12 上午10:04:12
	 * Description 检查验证码
	 */
	@ResponseBody
	@RequestMapping(params = "checkVerify")
    public AjaxJson checkVerify(HttpServletRequest request){
        AjaxJson result = new AjaxJson();
        String busType = request.getParameter("busType");
        String verifyCode = request.getParameter("verifyCode");
        System.out.println("SESSIONID：" +request.getSession().getId());
		result = zyCommonService.checkUserRandomCodeTimeout(request.getSession().getId(), busType, verifyCode);
		message="";
		result.setMsg(message);
        return result;
    }
	
	/**
	 * @author xiul
	 * 2017-4-11 下午12:56:42
	 * Description 上传快速报修的故障图片
	 */
	@ResponseBody
	@RequestMapping(params="uploadFaultPic")
	public AjaxJson uploadFaultPic(HttpServletRequest request){
		AjaxJson j = new AjaxJson();
		String oldFileName = oConvertUtils.getString(request.getParameter("fileName"));
		String compressFileStr = oConvertUtils.getString(request.getParameter("fileStream"));
		String suffix = ".jpg", fileName = UUID.randomUUID().toString().replace("-", "") + suffix;
		String uploadPath = StaticValue.UPLOAD_PATH + fileName;
		File file = new File(uploadPath);

		if(!compressFileStr.equals("")){
			try {
				BASE64Decoder decoder = new BASE64Decoder();
				compressFileStr = compressFileStr.substring(23);
				byte[] bt = decoder.decodeBuffer(compressFileStr);
				for (int i = 0; i < bt.length; i++) {
					if(bt[i] < 0){
						bt[i] += 256;
					}
				}
				OutputStream opt = new FileOutputStream(file);
				opt.write(bt);
				opt.flush();
				opt.close();

				ZyFileLogEntity zyfileLog = new ZyFileLogEntity();
				zyfileLog.setFilePath(file.getAbsolutePath());
				zyfileLog.setOldFileName(oldFileName);
				zyfileLog.setNewFileName(fileName);
				systemService.save(zyfileLog);
				j.setObj(zyfileLog.getId());
				System.out.println("上传成功！路径：" + file.getAbsolutePath());
			} catch (Exception e) {
				e.printStackTrace();
				j.setSuccess(false);
				j.setMsg("上传失败");
			}
		}else{
			System.out.println("上传文件码流为空");
		}

		return j;
	}
	/**
	 * @author mhg
	 * Description 上传快速报修的故障图片
	 */
	@ResponseBody
	@RequestMapping(params="uploadFaultPicNew")
	public AjaxJson uploadFaultPicNew(HttpServletRequest request){
		AjaxJson j = new AjaxJson();
		String oldFileName = oConvertUtils.getString(request.getParameter("fileName"));
		System.out.println("oldFileName---"+oldFileName);
		String oldFileName1="";
		if(StringUtil.isNotEmpty(oldFileName)){
			oldFileName1=oldFileName.substring(oldFileName.length()-4,oldFileName.length());
		}else{
			oldFileName1=".jpg";
		}
		String compressFileStr = oConvertUtils.getString(request.getParameter("fileStream"));
		if(StringUtil.isNotEmpty(oldFileName1) && oldFileName1.equals("jpeg")){
			oldFileName1=".jpg";
		}
		String oldFileName2="故障照片"+oldFileName1;
		String suffix =oldFileName1, fileName = UUID.randomUUID().toString().replace("-", "") + suffix;
		String uploadPath = StaticValue.UPLOAD_PATH + fileName;
		File file = new File(uploadPath);
		int count=23;
//		if(StringUtil.isNotEmpty(oldFileName1) && oldFileName1.equals(".jpg")){
//			count=23;
//		}

		if(!compressFileStr.equals("")){
			try {
				BASE64Decoder decoder = new BASE64Decoder();
				compressFileStr = compressFileStr.substring(count);
				byte[] bt = decoder.decodeBuffer(compressFileStr);
				for (int i = 0; i < bt.length; i++) {
					if(bt[i] < 0){
						bt[i] += 256;
					}
				}
				OutputStream opt = new FileOutputStream(file);
				opt.write(bt);
				opt.flush();
				opt.close();

				ZyFileLogEntity zyfileLog = new ZyFileLogEntity();
				zyfileLog.setFilePath(file.getAbsolutePath());
                zyfileLog.setOldFileName(oldFileName2);
                zyfileLog.setBusinessType("D");
                zyfileLog.setBusinessChildType("A");
				zyfileLog.setNewFileName(fileName);
				systemService.save(zyfileLog);
				j.setObj(zyfileLog.getId());
				System.out.println("上传成功！路径：" + file.getAbsolutePath());
			} catch (Exception e) {
				e.printStackTrace();
				j.setSuccess(false);
				j.setMsg("上传失败");
			}
		}else{
			System.out.println("上传文件码流为空");
		}

		return j;
	}


	/**
	 * 删除上传的文件
	 * @param request
	 * @return
	 */
	@ResponseBody
	@RequestMapping(params = "delFile")
	public AjaxJson delFile(HttpServletRequest request) {
		AjaxJson j = new AjaxJson ();
		try {
			String id = oConvertUtils.getString ( request.getParameter ( "id" ) );
			if (id != null && id != "") {
				systemService.deleteEntityById(ZyFileLogEntity.class, id);
				j.setMsg ("文件删除成功");
				j.setSuccess ( true );
			}
		} catch (Exception e) {
			j.setMsg ( e.getMessage () );
			j.setSuccess ( false );
			e.printStackTrace ();
		}
		return j;
	}

	/**
	 * @author xiul
	 * 2017-4-13 下午4:31:35
	 * Description 原微信快速报修订单列表
	 */
	@RequestMapping(params="quickRepairOrderList")
	public ModelAndView quickRepairOrderList(HttpServletRequest request){
		List<CbsQuickRepairEntity> qrs = cbsQuickRepairService.quickRepairOrderList(request);
		request.setAttribute("qrs", qrs);
		return new ModelAndView("com/wx/repair_query/quick_repair_ord_list");
	}

	/*
	* 现微信快速报修订单列表
	* 开发人：马宏刚
	* 时间：2018-04
	* */
	@RequestMapping(params="quickRepairOrderListNew")
	public ModelAndView quickRepairOrderListNew(HttpServletRequest request){
		String phone = request.getParameter("phone");
		TSUser user=genUser(request);
		String openId="";
		String cinemaName="";
		if(user!=null && StringUtil.isNotEmpty(user.getOpenId())){
            openId=user.getOpenId();
        }
        System.out.println("openId:"+openId);
		CbsWxUserBindEntity wxUser=systemService.singleResult("from CbsWxUserBindEntity where openId='"+openId+"'");
		if(wxUser!=null){
			cinemaName=wxUser.getCinemaName();
		}

		CbsServiceTypeEntity serviceType1=systemService.singleResult("from CbsServiceTypeEntity where name='故障维修' and type=0");
		String serviceTypeId="";
		if(serviceType1!=null){
			serviceTypeId=serviceType1.getId();
		}

		String sql="";
		//如微信用户是钻石（原金牌）用户,列表中显示该用户所属影院所有设备的服务单创建时间为最近3个月内的维修服务单
		if (StringUtil.isNotEmpty(user)&&StringUtil.isNotEmpty(user.getAuthenticationLevel()) && user.getAuthenticationLevel().equals("2")){
			sql="select cs.*,e.engineer_no AS engineerNo,e.`name` AS engineerName,e.cellphone AS engineerCellphone from cbs_service cs  left JOIN zy_engineer e ON cs.engineer_id=e.id  where cs.zy_cinema_name='"+cinemaName+"'and cs.service_type_1='"+serviceTypeId+"'  and source_type='2'  and cs.create_date>DATE_SUB(CURDATE(), INTERVAL 3 MONTH) ORDER BY create_date DESC";
		}else{
			//如微信用户不是钻石（原金牌）用户,列表中仅显示本人电话号码报修的且服务单创建时间为最近3个月内的维修服务单
			sql="select cs.*,e.engineer_no AS engineerNo,e.`name` AS engineerName,e.cellphone AS engineerCellphone  from cbs_service cs  left JOIN zy_engineer e ON cs.engineer_id=e.id where cs.contacts_phone='"+user.getMobilePhone()+"'and cs.service_type_1='"+serviceType1.getId()+"' and source_type='2'  and cs.create_date>DATE_SUB(CURDATE(), INTERVAL 3 MONTH) ORDER BY create_date DESC";
		}

		List<Map<String,Object>> serviceList = systemService.findForJdbc(sql);
		request.setAttribute("serviceList", serviceList);


//        List<ZyEngineerEntity> enginnerList=new ArrayList<>();
        List<CbsServiceReportEntity> reportList=new ArrayList<>();
//        List<ZyFileLogEntity> reportPhotoList=new ArrayList<>();
        List<ZyFileLogEntity> photoList=new ArrayList<>();
        List<ZyEmValidaRuleEntity> emValidaList=systemService.findHql("from ZyEmValidaRuleEntity ");//设备验证指标
		if(serviceList!=null && serviceList.size()>0){

			for(Map<String,Object> map:serviceList){

				//获取服务单对应的完工单
				List<CbsServiceReportEntity> cbsServiceReportEntityList = systemService.findHql("from CbsServiceReportEntity where serviceId.id='" + map.get("id")+"'" );
				if(cbsServiceReportEntityList!=null && cbsServiceReportEntityList.size()>0){
					reportList.add(cbsServiceReportEntityList.get(0));
				}

				//获取所有故障照片
				List<ZyFileLogEntity> fileLogEntityList=systemService.findHql("from ZyFileLogEntity where businessKey='"+ map.get("id")+"' and businessType='D' and businessChildType='A'");
				if(fileLogEntityList!=null && fileLogEntityList.size()>0){
					for(ZyFileLogEntity file:fileLogEntityList){
						photoList.add(file);
					}

				}

				//查询所有完工单照片
//				List<ZyFileLogEntity> reportPhotos=systemService.findHql("from ZyFileLogEntity where businessKey='"+map.get("id")+"'and businessType='XC5' and fileType='wgd'");
//				if(reportPhotos!=null && reportPhotos.size()>0){
//					for(ZyFileLogEntity zyFileLogEntity:reportPhotos){
//						reportPhotoList.add(zyFileLogEntity);
//					}
//				}

			}
//			request.setAttribute("enginnerList", enginnerList);
			request.setAttribute("reportList", reportList);
			request.setAttribute("photoList", photoList);
			request.setAttribute("emValidaList", emValidaList);
//			request.setAttribute("reportPhotoList", reportPhotoList);

		}

		//查询所有服务单对应的审批通过的备件申请(名称，数量，预计到货时间)

//		String  sql1="SELECT\n" +
//				"\tCOUNT(de.type_id) AS total,\n" +
//				"\tde.type_des AS type,\n" +
//				"\n" +
//				"cd.cr_code AS serCode,\n" +
//				"cd.expecttime AS expecttime\n" +
//				"FROM\n" +
//				"\t`cbs_deliver_equipment` de\n" +
//				"LEFT JOIN cbs_deliver cd ON cd.id=de.deliver_id\n" +
//				"GROUP BY\n" +
//				"\tde.type_id,de.deliver_id";


//		String sql1="SELECT\n" +
//				"cs.id AS id,\n" +
//				"ead.type_des AS `name`,\n" +
//				"ead.total AS total,\n" +
//				"cd.expecttime AS expecttime,\n" +
//				"cs.code AS serCode,\n" +
//				"cd.code AS code\n" +
//				"FROM\n" +
//				"cbs_equipment_apply_detail AS ead\n" +
//				"LEFT JOIN cbs_equipment_apply AS ea ON ea.id = ead.apply_id\n" +
//				"INNER JOIN cbs_service AS cs ON ea.service_id = cs.id\n" +
//				"LEFT JOIN cbs_deliver AS cd ON cd.equipment_apply_id = ea.id\n" +
//				"WHERE\n" +
//				"ea.`status` = '2'";
//		List<Map<String,Object>> appEqList=systemService.findForJdbc(sql1);
//		request.setAttribute("appEqList",appEqList);


		//查询所有服务单状态
		List<TSType> statusList=systemService.findHql("from TSType where TSTypegroup.typegroupcode='cbsServiceState'");
		request.setAttribute("statusList", statusList);

		//查询所有滤网状态
		List<TSType> lwTypes=systemService.findHql("from TSType where TSTypegroup.typegroupcode='lwzk'");
		request.setAttribute("lwTypes", lwTypes);

		request.setAttribute("user", user);

		return new ModelAndView("com/wx/repair_query/quick_repair_ord_list");
	}

	@RequestMapping(params = "sendPost")
	@ResponseBody
	public AjaxJson sendPost( HttpServletRequest request) throws Exception{
		AjaxJson j = new AjaxJson();

		String openId=request.getParameter("openid");
		String type=request.getParameter("type");

		String jsonString=wxCommonService.noticeAddLevel(openId,type);

		System.out.println("jsonString:"+jsonString);
		j.setMsg(message);
		j.setObj(jsonString);
		return j;
	}



    public TSUser genUser(HttpServletRequest request){
        TSUser u = ResourceUtil.getSessionUserName();
        if(null == u){
            String openId = oConvertUtils.getString(request.getSession().getAttribute("openId")) ;
            u = zyCommonService.findUniqueByProperty(TSUser.class,"openId", openId);
        }
        return u;
    }


    //测试生成服务单号
    @RequestMapping(params = "testGetNo")
    @ResponseBody
    public AjaxJson testGetNo( HttpServletRequest request) throws Exception{
        AjaxJson j = new AjaxJson();

        Map map=cbsServiceServiceI.getNo();
        String code=(String) map.get("no");
        j.setObj(map);
        return j;
    }

}
